﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Chbl.Models
{
    public class Game
    {
        public int GameId { get; set; }
        public int HomeTeamId { get; set; }
        public int RoadTeamId { get; set; }
        [Display(Name = "Хозяева")]
        public virtual Team HomeTeam { get; set; }
        [Display(Name = "Гости")]
        public virtual Team RoadTeam { get; set; }
        [Display(Name = "Дата игры")]
        public DateTime Date { get; set; }
        [Display(Name = "Номер игры")]
        public int GameOrder { get; set; }
        [Display(Name = "Номер тура")]
        public int TourNumber { get; set; }
        public int SeasonDivisionId { get; set; }
        public virtual SeasonDivision SeasonDivision { get; set; }
        [Range(0,200)]
        public int? HomeScore { get; set; }
        [Range(0, 200)]
        public int? RoadScore { get; set; }
        [DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "Не сыграна")]
        [Display(Name = "Счет")]
        public string Score
        {
            get { return (HomeScore.HasValue || RoadScore.HasValue )
                    ? string.Format("{0}:{1}", HomeScore, RoadScore)
                    : string.Empty;}
        }

        [Display(Name = "Техническое поражение")]
        public bool? TechnicalDefeat { get; set; }
    }
}